/**
 * @file createBoolField
 * @author fanxueliang@qq.com
 */
import type {BoolSpecItem, BoolLikeField} from '../interface';
import {getBasicField} from '../util';

export function createBoolField(spec: BoolSpecItem, showIndex: number, path: string) {
    let component = 'Switch';
    if (spec.ui) {
        component = spec.ui;
    }
    const basicField = getBasicField(spec, path, showIndex);

    return {
        ...basicField,
        type: 'BOOL',
        isLeaf: true,
        spec,
        component
    } as BoolLikeField;
}
